<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@include file="/common/common.jsp"%>
<%@include file="/common/skins/skin0/component.jsp" %>
<h:css href="/css/style1/style-custom.css"/>
<%--
- Author(s): pengweiling
- Date: 2012-07-06 08:57:21
- Description:
--%>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>
      订单详情
    </title>
    <script>
      //配置参数
      <% int ic = 0; %>
      gCfg = {
      <l:iterate property="cfg" id="id1">
         <% if (ic > 0){%>
         ,
         <%} %>
         '<b:write property="parameterCode" iterateId="id1"/>':'<b:write property="parameterValue" iterateId="id1"/>'
         <%ic++; %>
      </l:iterate>
      };
      
      //折扣规则
      <%ic=0; %>
      gRules = [
         <l:iterate property="rules" id ="id2">
         <% if (ic > 0){%>
         ,
         <%} %>
         {
           cCategory:'<b:write property="ccategory" iterateId="id2"/>',
           ndaysfrom:<b:write property="ndaysfrom" iterateId="id2"/>,
           ndaysto:<b:write property="ndaysto" iterateId="id2"/>,
           nratediscount:<b:write property="nratediscount" iterateId="id2"/>
         }
         <%ic++; %>
         </l:iterate>
      ];
    </script>    
    
<%
  String ua = request.getHeader( "User-Agent" );
  boolean isMSIE = ( ua != null && ua.indexOf( "MSIE" ) != -1 );
  if (isMSIE==true){

%>
<script type="text/javascript" src="OrderMgr/script/json2.js"></script>  
  
<%} %>  
    <script type="text/javascript" src="commonPick/script/utils.js"></script>    
    <script type="text/javascript" src="OrderMgr/script/order.js"></script>
    <script type="text/javascript" src="OrderMgr/script/orderAjax.js"></script>
    
<style>
   .eos-body-div{
     width:100% !important;
   }
</style>

  </head>
  <body>             
    <e:datasource name="weordertasks" type="entity" path="com.hms.OrderMgr.order.WeOrdertasks" />
    <h:form name="data_form" action="com.hms.OrderMgr.Warkin.flow" method="post" onsubmit="return submitDatacell(this);">
      <h:hidden property="weordertasks/iorderid" />
      <input type="hidden" id="depositSaved" value="N">
      <input type="hidden" name="_eosFlowAction" value="update" >
      <h:hiddendata property="criteria" />
      <h:hidden property="page/begin"/>
      <h:hidden property="page/length"/>
      <h:hidden property="page/isCount"/>
      <w:panel id="pnl" title="订单信息">
      <dataform id= "efa30c85-dbed-4340-a754-267fa9a49981">
          <table align="center" border="0" width="100%" class="form_table">
            <tr>
               <td class="form_label">
                  订单编号
               </td>
              <td colspan="5" style="color:blue">
                <b:write property="weordertasks/corderno"/>
              </td>               
            </tr>
            <tr>
              <td class="form_label">
                预订人
              </td>
              <td colspan="1">
                <h:text property="weordertasks/cbookname" style="width:200px;" validateAttr="allowNull=false" readonly="true" /><font style="color:red">*</font>
              </td>
              <td class="form_label">
                预订人手机
              </td>
              <td colspan="1">
                <h:text property="weordertasks/cbooktel"  style="width:200px;" readonly="true" />
              </td>
              <td class="form_label">
                预定会员
              </td>
              <td colspan="1">
                <w:lookup property="weordertasks/cbookmemberid"  
                          displayProperty="weordertasks/memberName"
                          style="width:200px;" 
                          dialogTitle="选择会员"
                          allowInput="false"
                          readOnly="true" 
                          lookupUrl="com.hms.commonPick.WeMemberSelect.flow"/>

              </td>
            </tr>
            <l:notEqual property="weordertasks/csourcename" targetValue="WalkIn">
            <tr>
              <td class="form_label">
                是否接机
              </td>
              <td colspan="1">
                <h:switchCheckbox checkedValue="Y" property="weordertasks/bispickup" uncheckedValue="N" disabled="true"/>
              </td>
              <td class="form_label">
                接机时间
              </td>
              <td colspan="1">
                <w:date property="weordertasks/dpickupdate" style="width:200px;" readOnly="true"  format="yyyy-MM-dd HH:mm:ss" />
              </td>
              <td class="form_label">
                销售员
              </td>
              <td colspan="1">
                <w:lookup property="weordertasks/csaler" 
                          style="width:200px;"
                          lookupUrl="com.hms.commonPick.OmEmployeeSelect.flow"
                          displayProperty="weordertasks/salesName"      
                          dialogTitle="选择销售员"  
                          readOnly="true"  
                          validateAttr="allowNull=false"
                          allowInput="false"/><font style="color:red">*</font>
              </td>
            </tr>            
            </l:notEqual>            
            <tr>
              <td class="form_label">
                是否送机
              </td>
              <td colspan="1">
                <h:switchCheckbox checkedValue="Y" property="weordertasks/bisseeoff" uncheckedValue="N" disabled="true"/>
              </td>
              <td class="form_label">
                送机时间
              </td>
              <td colspan="1">
                <w:date property="weordertasks/dseeoffdate" style="width:200px;"  format="yyyy-MM-dd HH:mm:ss" disabled="true"/>
              </td>
              <td class="form_label">
                送机目的地
              </td>
              <td colspan="1">
                <h:text property="weordertasks/cseeoffaddress" style="width:200px;" readonly="true"/>
              </td>
            </tr>
            <tr>
              <td class="form_label">
                客人来源
              </td>
              <td colspan="1">
                <d:select property="weordertasks/csourcename" style="width:200px;"  nullLabel="请选择" dictTypeId="HMS_CUSTOMER_SRC" disabled="true"/>
              </td>
              <td class="form_label">
                来源说明
              </td>
              <td colspan="3">
                <h:text property="weordertasks/csoucedescription" style="width:100%;" readonly="true"/>
              </td>
            </tr>            
            <tr>
              <td class="form_label">
                总金额
              </td>
              <td colspan="1">
                <input type="text" id="txtPriceAmt" style="width:200px;" readonly="true"  />
                <input type="hidden" id="txtOriginAmt"/>
                <input type="hidden" id="txtDiscount"/>
                <input type="hidden" id="txtPrepayAmt"/>
                <input type="hidden" id="txtCommision"/>                
                <input type="hidden" name="weordertasks/npaypercent" id="txtPrepayPercent" value="1"/>
              </td>            
              <td class="form_label">
                付款方式
              </td>
              <td colspan="1">
                <d:select property="weordertasks/cpaymenttype" style="width:200px;" nullLabel="请选择" dictTypeId="HMS_PAYMENT_TYPE" disabled="true"/>
              </td>
              <td class="form_label">
                付款摘要
              </td>
              <td colspan="1">
                <h:text property="weordertasks/cpaymentdescription" style="width:100%;" readonly="true"/>
              </td>
            </tr>
            <tr>
              <td class="form_label">
                备注
              </td>
              <td colspan="5">
                <h:textarea property="weordertasks/cdescription" style="width:100%;" readonly="true"/>
              </td>
            </tr>
            <tr class="form_bottom">
              <td colspan="6">
                <input type="button" class="button" onclick="history.go(-1)" value="返回"> 
              </td>
            </tr>
          </table>
      </dataform>
</w:panel>
      <w:layout height="70%" type="vertical" width="100%">
         <w:layoutPanel height="20%" width="100%">
            <w:layout height="100%" type="horizontal" width="100%">
              <w:layoutPanel width="60%" height="100%"> 
                 <r:datacell readonly="true" height="250" pageSize="1000" entityType="com.hms.OrderMgr.order.WeGres" id="gress" isCount="false" readonly="false" submitXpath="weordertasks/gress" width="100%" xpath="weordertasks/gress">
                   <r:toolbar location="top" tools="edit:refresh"/>
                   
                   <r:field fieldName="cgresno" label="客单号" nullText="必须输入" width="90">

                   </r:field>
                                      
                   <r:field fieldName="roomno" label="房号" width="170"/>

                                      
                   <r:field fieldName="arrorigdate" label="抵店日期" width="180" onRefreshFunc="getArrDate" >

                   </r:field>
                              
                   <r:field fieldName="deporigdate" label="离店日期" onRefreshFunc="getDepDate" width="180">

                   </r:field>
                              
                   <r:field fieldName="daycount" label="房晚数" onRefreshFunc="getDayCount" width="65">
                   </r:field>
                      
                   <r:field fieldName="cstatus" label="状态" onRefreshFunc="getGresStatus" width="65">
                   </r:field>   
                   
           <r:field fieldName="roomarea" label="区域"  width="70">
           </r:field>
           <r:field fieldName="areaname" label="小区"  width="70">
           </r:field>
           <r:field fieldName="buildingno" label="栋号" width="70">
           </r:field>
           <r:field fieldName="roomtype" label="房型" width="70">
           </r:field>   
           
                 </r:datacell>
              </w:layoutPanel>
              
              <w:layoutPanel width="40%" height="100%">
                <r:datacell pageSize="1000" id="grdSchedule" height="250"  width="100%" linkId="gress" linkField="schedules">
                   <r:toolbar location="top" tools="edit:refresh"/>
                   <r:field fieldName="dbusinessdate" label="入住日期"></r:field>
                   <r:field fieldName="nrate" label="房价/晚"></r:field>   
                   <r:field fieldName="cstatus" label="状态" onRefreshFunc="showScheduleStatus"></r:field>                                                   
                </r:datacell>                
              </w:layoutPanel>
            </w:layout>
         </w:layoutPanel>
         <w:layoutPanel height="80%" width="100%">         
           <w:tabPanel bodyStyle="" defaultTab="tabEntry" height="100%" id="pgInfo" titleStyle="" width="100%">              
              <w:tabPage cache="true" id="tabEntry" tabType="div" title="入住信息">
                <%@include file="/OrderMgr/EntryInfo.jsp" %>
              </w:tabPage> 
              <w:tabPage cache="true" id="tabBill" tabType="div" title="账单">
                <%@include file="/OrderMgr/Bill.jsp" %>
              </w:tabPage> 
           </w:tabPanel>
         </w:layoutPanel>
      </w:layout>

      
    </h:form>
    <script>
      function submitDatacell(frm) {
      
        //检查客单是否已经收取房费和押金
        if (checkBillDeposit() == false){
           return false;
        }
        
        if (checkForm(frm)) {
          var dcell = $id('gress'); 
          dcell.submitAllByHidden();
          //dcell.submitModifyByHidden();
          return true;
        }

        return false;
      }
      
      $id("gress").afterAdd = synGresAdd;
      $id("gress").afterDel = afterGressDelete;
      $id("gress").afterEdit = synGresEdit;
      $id("gress").afterSelectRow = function(){
        afterSelectRow();
        calBalanceAmt();}
      $id("gress").beforeSelectRow = beforeSelectRow;
            
      //line grid event
      $id("grdSchedule").afterAdd = sumAmount;
      $id("grdSchedule").afterDel = sumAmount;
      $id("grdSchedule").afterEdit = sumAmount;
      
      
      
      <%
        if (isMSIE==true){
       %>
         $id("btnCheckIn").attachEvent("onclick", function(){
           if (!canCheckIn($id("gress").getActiveEntity())){
             return;
           } 
           checkIn($id("gress").getActiveEntity()); 
           gCheckInChanged = false;});
       <%}else{ %>
         $id("btnCheckIn").addEventListener("click", function(){
           if (!canCheckIn($id("gress").getActiveEntity())){
             return;
           } 
           checkIn($id("gress").getActiveEntity()); 
           gCheckInChanged = false;});       
       <%} %>
      
      bindCheckInEvent();
      
      bindHandlerEvent();

      
      var func = $id("gress").loadData;

      
      
      function setRoomId(args){         
         $id("gress").activeEntity.setPropertyByFieldName("iroomid", args[0]);
      }

      //开始刷新
      gressRefreshQueue();
      
      <l:equal property="_eosLastAccessAction" targetValue="insert">
        $id("txtPrepayPercent").value = gCfg.PREPAY_PERCENT + "";
      </l:equal>
      
      
      setTimeout(function(){
        getTotalAmt("nrate", "txtPriceAmt");
      }, 1000);
      

    </script>
  </body>
</html>
